-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
i18n lib change - use htmr to parse html inside json files #8585 #8592
Conversation
✅ ethereum-org-website-react-i18n deploy preview ready
|
The last build (triggered manually) was successful. https://www.gatsbyjs.com/dashboard/5e02f963-3fe5-4e37-a1e7-ac05f7753a86/sites/cd906ab6-d953-4705-ba62-6d4128ac2d8a/pull-requests/84607095-38e5-445a-b917-7942e45fa276/builds |
src/components/Translation.tsx
Outdated
const transform = { | ||
a: Link, | ||
} | ||
|
||
// Wrapper on <FormattedHTMLMessage /> to always fallback to English |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems this explanation is now out of date (given we swapped i18n libs)? Does it still fallback to English?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. Yea, I'll update that comment. And yes, it fallback to English.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, in const { t } = useTranslation()
, the t
function is the one that fallback to English.
id: string | ||
} | ||
|
||
const transform = { | ||
a: Link, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the only element we'd want a custom component for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So far I haven't seen any other html element on the translation files where we would want to use a custom React component.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple small questions but overall this seems like a much cleaner way to accomplish this!
6f95d97
to
45124c8
Compare
This PR removes the usage of
dangerouslySetInnerHTML
(for security reasons) to insert html content from the translation files. Instead, it uses the htmr lib where we can also use our own custom components (similar to what we do with markdown files).Description
dangerouslySetInnerHTML
htmr
to parse the inner html that json files may haveRelated Issue
#8345